package handle;

import common.Constants.ServiceConstant;
import common.Result;
import dataBean.StudentScoreDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import service.ScoreService;
import service.VerifyService;

/**
 * Created by lxl on 2015/11/8.
 */
@Controller
@RequestMapping("ssms/modify")
public class UpdateScoreHandle {

    @Autowired
    private ScoreService scoreService ;

    @Autowired
    private VerifyService verifyService ;

    @RequestMapping(value = "/score",method = RequestMethod.POST)
    public @ResponseBody
    Result process( @RequestBody StudentScoreDo studentScoreDo , @RequestHeader String token ){

        Result result = verifyService.verify(token, ServiceConstant.TEACHER_LEVEL) ;

        if( result.isSucces() ){

            result = scoreService.updateScore(studentScoreDo.getScoresDo() , studentScoreDo.getScoreInfoDo()) ;

        }

        return result ;

    }

}
